<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>校园生活信息网登录</title>
    <!-- Custom Theme files -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/loginstyle.css">
    <!-- Custom Theme files -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="登录" />
    <!--Google Fonts-->
    <!--<link href='//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
    --><!--Google Fonts-->
</head>
<body>
<!--header start here-->
<div class="login-form">
    <div class="top-login">
        <span><img src="${pageContext.request.contextPath}/images/group.png" alt=""/></span>
    </div>
    <h1>校园生活信息网</h1>
    <div class="login-top">

            <div class="login-ic">
                <i ></i>
                <input type="text"  name="username" id="username" placeholder="请输入学号或工号！"/>
                <div class="clear"> </div>
            </div>
            <div class="login-ic">
                <i class="icon"></i>
                <input type="password"  name="password" id="password" placeholder="请输入密码！"/>
                <div class="clear"> </div>
            </div>

            <div class="log-bwn">
                <input type="submit"  value="登录" onclick="requestJson()">
            </div>

    </div>

    <a href="${pageContext.request.contextPath}/user/SMS" ><p class="copy">忘记密码?</p></a>
    <span style="color:burlywood">温馨提示：首次登录密码为：123，登录成功后，请尽快修改密码和绑定手机号！</span>
</div>


<!--header start here-->
<script src="${pageContext.request.contextPath}/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    function requestJson(){

        var name =$("#username").val();//#是id选择器
        var pwd =$("#password").val();
        if(name==""){
            alert("用户名不能为空！");
            return false;
        }
        else if(pwd==""){
            alert("密码不能为空！");
            return false;
        }
        else
        {
            $.ajax({
                type:'post',
                url:'${pageContext.request.contextPath}/login/login_verify',
                dataType:"json",//注意使用的是打他dataType，而不是Content-Type
                async: true,
                data:{username:name,password:pwd},
                success:function(data){
                    if(data==0){

                        window.location.href ="${pageContext.request.contextPath}/login/record";
                    }
                    else{
                        alert("账号或密码错误！")

                    }
                }
            });
        }
    }
</script>
</body>
</html>